﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sys_range_frame.aspx.cs" Inherits="Ccit.UserControls.sys_range_frame" %>
<html>
<head runat="server">
    <title id="PageTitle" runat="server">范围选择页面</title>
    <script src="../script/jquery.js" type="text/javascript"></script>
    <script src="../script/jbase64.js" type="text/javascript"></script>
    <script src="../script/jbase64.js" type="text/javascript"></script>
    <script type="text/javascript">
    <!--
        function doConfirm() {
            var vinsetType = $get("_hidInsetType").value;
            var vctrlRangeType = $get("_hidCtrlRangeType").value;
            var vctrlRangeId = $get("_hidCtrlRangeId").value;
            var vctrlRangeName = $get("_hidCtrlRangeName").value;
            var vselType = $get("_hidSelType").value;
            var vcallMethod = $get("_hidCallMethod").value;
            var arrList = self.frames[1].GetSelectedValue();
            var actRangeType = getRangeType(vselType);
            if(vinsetType == "0") {  //弹出式
                if(vselType == "9") {
                    opener.window.document.getElementById(vctrlRangeType).value = actRangeType;                    
                }
                opener.window.document.getElementById(vctrlRangeId).value = arrList[0];
                opener.window.document.getElementById(vctrlRangeName).value = arrList[1];
                if(jQuery.trim(vcallMethod) != "") {
                    eval("opener.window." + vcallMethod + "('" + arrList[0] + "','" + arrList[1] + "')");
                }
               
            }
            else {
            
            }
            
            window.close();
        }
        
        function getRangeType(pselType) {
            
            var vRetType = "";
            if(pselType == "9") {
                var oRadioArray = document.getElementsByName("rdRangeType");
                var oRadio;
                var iLen = oRadioArray.length;
                for(var i = 0; i < iLen; i ++) {
                    oRadio = oRadioArray[i];
                    if(oRadio.checked) {
                        vRetType = oRadio.value;
                        break;
                    }
                }
            }
            
            return vRetType;
        }
        
        function doCancel() {
            window.close();
        }
        
        function doRadioChange(pType) {
            var vOrganId = $get("_hidOrganId").value;
            var vSeparator = $get("_hidSeparator").value;
            var vPageParam = "";
            var encodeParam = "";
            if(pType == "0") {
                vPageParam = "organid=" + vOrganId;
                encodeParam = base64encode(vPageParam);
                self.frames[0].document.location.href = "./range_clause_set.aspx?" + encodeParam;
                $("#tdfrmClause").eq(0).width("35%");
                $("#tdfrmSelect").eq(0).width("65%");
            }
            else {
                $("#tdfrmClause").eq(0).width("0");
                $("#tdfrmSelect").eq(0).width("100%");
            }
            
            vPageParam = "organId=" + vOrganId + "&rangetype=" + pType + "&sep=" + vSeparator;
            encodeParam = base64encode(vPageParam)
            self.frames[1].document.location.href = "./sys_range_select.aspx?" + encodeParam;
        }
    //-->
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <input type="hidden" id="_hidOrganId" runat="server" />
        <input type="hidden" id="_hidSelType" runat="server" /><!--作为范围选择，用户选择，部门、职位、级别选择的通用控件标识 -->        
        <input type="hidden" id="_hidRangeType" runat="server" />
        <input type="hidden" id="_hidRangeId" runat="server" />
        <input type="hidden" id="_hidRangeName" runat="server" />
        <input type="hidden" id="_hidCtrlRangeType" runat="server" />
        <input type="hidden" id="_hidCtrlRangeId" runat="server" />
        <input type="hidden" id="_hidCtrlRangeName" runat="server" />
        <input type="hidden" id="_hidSeparator" runat="server" />
        <input type="hidden" id="_hidInsetType" runat="server" /><!-- 嵌入选择控件类型 0: overflow 1: 弹出 -->
        <input type="hidden" id="_hidCallMethod" runat="server" />
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <table class="tbToolbar" cellpadding="0" cellspacing="0" width="98%" align="center">
            <tr>
                <td align="center">
                    <div class="tbSeparator"></div>
                </td>
                <td width="100%" class="titlebar">
                    <asp:Label ID="lbTitle" runat="server">范围选择</asp:Label>
                </td>
                <td align="right">
                    <div class="tbSeparatorEnd"></div>
                </td>
            </tr>
        </table>
        <table id="tblRangeType" class="tableborder" cellpadding="0" cellspacing="0" width="98%" align="center" runat="server">
            <tr>
                <td width="15%" class="pformleft" align="center"><nobr>范围类型</nobr></td>
                <td width="85%" class="pformright">
                    &nbsp;
                    <input type="radio" id="rdAllUser" name="rdRangeType" onclick="doRadioChange('9')" value="9">全部人员&nbsp;
                    <input type="radio" id="rdUser" name="rdRangeType" onclick="doRadioChange('0')" value="0">按人员&nbsp;
                    <input type="radio" id="rdDept" name="rdRangeType" onclick="doRadioChange('1')" value="1">按部门&nbsp;
                    <input type="radio" id="rdPos" name="rdRangeType" onclick="doRadioChange('2')" value="2">按职位&nbsp;
                    <input type="radio" id="rdClass" name="rdRangeType" onclick="doRadioChange('3')" value="3">按级别&nbsp;
                    <!--<input type="radio" id="rdWorkGroup" name="rdRangeType" onclick="doRadioChange('4')" value="4">按工作组&nbsp;-->
                    <!--<input type="radio" id="rdCustom" name="rdRangeType" onclick="doRadioChange('5')" value="5">自定义&nbsp; -->
                </td>
            </tr>
         </table>
         <table class="tableborder" cellpadding="0" cellspacing="0" width="98%" height="320px" align="center">
            <tr height="100%">
                <td id="tdfrmClause" width="35%" align="center" valign="top">
                    <iframe id="ifrmClause" name="ifrmClause" width="100%" height="100%" style="border-right:1px solid black" frameborder="0"
                       marginheight="0" marginwidth="0"  src="" scrolling="no" runat="server"></iframe>
                </td>
                <td id="tdfrmSelect" width="65%">
                    <iframe id="ifrmSelect" name="ifrmSelect" width="100%" height="100%" marginheight="0" frameborder="0" src="" scrolling="no" runat="server"></iframe>
                </td>
            </tr>
            <tr class="pformstrip">
                <td colspan="2" width="100%" align="center">
                    <input type="button" id="btnConfirm" class="button" onclick="doConfirm()" value="确定" />
                    &nbsp;&nbsp;
                    <input type="button" id="btnCancel" class="button" onclick="doCancel()" value="取消" />
                </td>
            </tr>
        </table>
    
    <script type="text/javascript">
    <!--
        $(document).ready(function() {
            var vselType = $get("_hidSelType").value;
            var vinsetType = $get("_hidInsetType").value;
            var vctrlRangeType = $get("_hidCtrlRangeType").value;
            var vctrlRangeId = $get("_hidCtrlRangeId").value;
            var vctrlRangeName = $get("_hidCtrlRangeName").value;

            if (vinsetType == "0") { //弹出式
                if (vselType == "9")
                    $get("_hidRangeType").value = opener.window.document.getElementById(vctrlRangeType).value;
                $get("_hidRangeId").value = opener.window.document.getElementById(vctrlRangeId).value;
                $get("_hidRangeName").value = opener.window.document.getElementById(vctrlRangeName).value;
            }
            else { //overflow
                if (vselType == "9")
                    $get("_hidRangeType").value = $get(vctrlRangeType).value;
                $get("_hidRangeId").value = $get(vctrlRangeId).value;
                $get("_hidRangeName").value = $get(vctrlRangeName).value;
            }

            var vRangeType = $get("_hidRangeType").value;
            var vOrganId = $get("_hidOrganId").value;
            var vSeparator = $get("_hidSeparator").value;

            if (vselType == "9") {
                vRangeType = (vRangeType == "") ? "9" : vRangeType;
                var ctrlRdRangeType = new RadioList("rdRangeType");
                ctrlRdRangeType.setCheckedItem(vRangeType);
            }


            var vPageParam = "";
            var encodeParam = "";
            if (vRangeType == "0") {
                vPageParam = "organid=" + vOrganId + "&sep=" + vSeparator;
                encodeParam = base64encode(vPageParam);
                self.frames[0].document.location.href = "./range_clause_set.aspx?" + encodeParam;
                $("#tdfrmClause").eq(0).width("35%");
                $("#tdfrmSelect").eq(0).width("65%");
            }
            else {
                $("#tdfrmClause").eq(0).width("0");
                $("#tdfrmSelect").eq(0).width("100%");
            }

            vPageParam = "organid=" + vOrganId + "&rangetype=" + vRangeType + "&sep=" + vSeparator;
            encodeParam = base64encode(vPageParam);
            self.frames[1].document.location.href = "./sys_range_select.aspx?" + encodeParam;
        });
    //-->
    </script>
        
    </form>
    
    </body>
</html>
